package com.hoo.service.equipment;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springside.modules.mapper.BeanMapper;

import com.hoo.entity.equipment.Venue;
import com.hoo.form.equipment.VenueForm;
import com.hoo.mapper.equipment.VenueMapper;
import com.hoo.util.PaginationSupport;


@Service
public class VenueService {

	
	@Autowired
	VenueMapper venueMapper;
	
	public Venue getVenueById(int id){
		return this.venueMapper.getVenueById(id);
	}
	
	public int addVenue(VenueForm form){
		Venue venue=BeanMapper.map(form, Venue.class);
		venue.setAddTime(new Date());
		return this.venueMapper.insertVenue(venue);
	}
	
	public int updateVenue(VenueForm form){
		Venue venue=BeanMapper.map(form, Venue.class);
		venue.setUpdateTime(new Date());
		return this.venueMapper.updateVenue(venue);
	}

	public int deleteVenue(int id){
		return this.venueMapper.deleteVenueById(id);
	}
	
	public PaginationSupport<Venue> search() {
		int totalCount = this.venueMapper.getVenueCount();
		List<Venue> list = this.venueMapper.getVenueList();
		return new PaginationSupport(list, totalCount);
	}
	
	public List<Venue> getAllVenue(){
		return this.venueMapper.getAllVenue();
	}

	public Venue getVenue(VenueForm form) {
		return this.venueMapper.getVenue(form);
	}
}
